package org.skyeye.modeling.commands;

import org.eclipse.gef.commands.Command;
import org.skyeye.modeling.model.MConnection;
import org.skyeye.modeling.model.MNode;
import org.skyeye.modeling.model.MSOC;
public class DeleteConnectionCommand extends Command {

	private MNode source;

	private MNode target;

	private MConnection connection;

	//Setters
	public void setConnection(MConnection connection) {
		this.connection = connection;
	}

	public void setSource(MNode source) {
		this.source = source;
	}

	public void setTarget(MNode target) {
		this.target = target;
	}

	public void execute() {
		source.removeOutput(connection);
		target.removeInput(connection);
		source.disconnectAllInterface(connection);
		target.disconnectAllInterface(connection);
	}

	public String getLabel() {
		return "";
	}

	public void redo() {
		execute();
	}

	public void undo() {
		connection.setSource(source);
		connection.setSink(target);
		source.addOutput(connection);
		target.addInput(connection);
		/*source.connectOnAllInterface(connection);
		target.connectOnAllInterface(connection);*/
	}
	public MConnection getConnection(){
		return this.connection;
	}
}